home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1990-1992, 1994 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the name of Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
- * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
- // -*- C++ -*-
-
- /*
- * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
- *
- _______________________________________________________________________
- ______________ S I L I C O N G R A P H I C S I N C . ____________
- |
- | $Revision: 1.1008 $
- |
- | Description:
- | This file contains the MyColorSlider class which is an MySlider
- | (GL slider within an GLX widget) with build in policies. You can only
- | build a set of pre-defined color sliders (see Type enum below).
- |
- | Classes:
- | MyColorSlider
- |
- | Author(s) : Alain Dumesny
- |
- ______________ S I L I C O N G R A P H I C S I N C . ____________
- _______________________________________________________________________
- */
-
- #ifndef _SO_XT_COLOR_SLIDER_
- #define _SO_XT_COLOR_SLIDER_
-
- #include "MySlider.h"
-
- class SbColor;
- class SbVec2f;
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // Class: MyColorSlider
- //
- // This class defines the color slider which is a set of predefined
- // sliders (R, G, B, H, S, V,..) with special behaviors.
- //
- //////////////////////////////////////////////////////////////////////////////
-
- // C-api: prefix=SoXtColSldr
- class MyColorSlider : public MySlider {
-
- public:
-
- //
- // list of color sliders types
- //
- enum Type {
- RED_SLIDER,
- GREEN_SLIDER,
- BLUE_SLIDER,
- HUE_SLIDER,
- SATURATION_SLIDER,
- VALUE_SLIDER,
- INTENSITY_SLIDER, // independent of the slider value
- };
-
- // Constructor/Destructor
- MyColorSlider(
- Widget parent = NULL,
- const char *name = NULL,
- SbBool buildInsideParent = TRUE,
- MyColorSlider::Type type = INTENSITY_SLIDER);
- ~MyColorSlider();
-
- //
- // Routine used to specify the slider value and also the top region
- // color (WYSIWYGmode in most cases). Users should call this routine
- // instead of the base class setValue() routine if they want the color
- // slider top region to correctly reflect the current color.
- // (code is optimized for WYSIWYGmode off)
- //
- // NOTE: routine expects
- // an rgb color for R, G or B slider type
- // an hsv color for H, S, or V slider type
- // an rgb color for Intensity slider type
- //
- // NOTE: if calling setBaseColor() changes the thumb position the
- // valueChanged callbacks will be called with the new value.
- //
- // C-api: name=setBaseCol
- void setBaseColor(const float rgbOrHsv[3]);
- // C-api: name=getBaseCol
- const float *getBaseColor() { return color; }
-
- //
- // This routine sets the WYSIWYG (What You See Is What You Get) mode
- // to be true or false (default FALSE). Immediate mode.
- // This has no effect on monochrome sliders.
- //
- void setWYSIWYG(SbBool trueOrFalse); // default FALSE
- SbBool isWYSIWYG() { return WYSIWYGmode; }
-
- // returns the type of the slider
- MyColorSlider::Type getType() { return type; }
-
- protected:
-
- // This constructor takes a boolean whether to build the widget now.
- // Subclasses can pass FALSE, then call MySlider::buildWidget()
- // when they are ready for it to be built.
- SoEXTENDER
- MyColorSlider(
- Widget parent,
- const char *name,
- SbBool buildInsideParent,
- MyColorSlider::Type type,
- SbBool buildNow);
-
- // redefine this routine to cache slider top geometry
- virtual void sizeChanged(const SbVec2s &newSize);
-
- // redefine this routine to do the actual slider top region drawing.
- // This routine is automatically called by the MySlider::redraw() routine.
- virtual void drawSliderTopRegion();
-
- private:
-
- // local vars
- Boolean WYSIWYGmode;
- Type type;
- float color[3];
- SbColor *defaultColors, *colors;
- SbVec2f *geometry;
-
- // routine that make the default and WYSIWYG colors
- void makeDefaultColors();
- void makeWYSIWYGcolors();
-
- static void sliderChangedCB(void *, float val);
-
- // this is called by both constructors
- void constructorCommon(MyColorSlider::Type type, SbBool buildNow);
- };
-
-
- #endif /* _SO_XT_COLOR_SLIDER_ */
-